
/*
		*
		*
		*通用模板
		*打开input或者返回list页面
		*/
		
		//打开或返回list页面
function showPHiRPList() {
	window.location.href("list.html");
}
		
		//打开input页面，在新增的时候，也有下一步的时候用?
function showPHiRP() {
	window.location.href("input.html");
}
		
		//打开detail页面，在查看详情的时候，会用到生成下一个单?
function showPHiRPDetail() {
	window.location.href("detail.html");
}
/*
		*
		*鼠标单击某一行变颜色
		*/
function mouseclick(o, a, b, d) {
	var t = document.getElementById(o).getElementsByTagName("tr");
	for (var k = 1; k < t.length; k++) {
		t[k].onclick = function () {
			for (var j = 1; j < t.length; j++) {
				t[j].style.backgroundColor = (t[j].rowIndex % 2 == 0) ? a : b;
			}
			this.style.backgroundColor = d;
		};
	}
}
/*
		*
		*
		*财务处理模块
		*
		*/
		
		//返回或打开"select.html"页面
function showPHiRPSelect() {
	window.location.href("select.html");
}
/*
		*
		*
		*存货核算模块
		*
		*/
		
		//进入查看勾稽关系页面函数		
function showPHiRPArticulation() {
	window.location.href("articulation/list.html");
}

		//进入查看组装拆卸修改页面函数		
function showPHiRPStoragecontrol() {
	window.location.href("../../storage/ckd/input.html");
}
		//返回组装拆卸核算页面函数		
function showPHiRPStoragecontrolpackagelist() {
	window.location.href("../../storagecontrol/package/list.html");
}
		
		//结束		
function showPHiRPOutcheckEnd() {
	window.location.href("end.html");
}
function showCalculationProject() {
	var a = document.getElementById("subject_set");
	var b = document.getElementById("calculation_project");
	a.style.display = "none";
	b.style.display = "block";
}
function showSubject() {
	var a = document.getElementById("subject_set");
	var b = document.getElementById("calculation_project");
	b.style.display = "none";
	a.style.display = "block";
}

//显示销售价格资料
function showPrice() {
	window.location.href("price/list.html");
}
/*
*
*
*动态添加领料出库详情
*/
/*
function addDetail() {
	var t = document.getElementById("mbody");
	var row = t.insertRow(t.rows.length);
	var i = t.rows.length - 2;
	var id = "textSuggest" + i;
	var col = row.insertCell(0);
	col.innerHTML = "<td><input  type='checkbox' name='checkbox'/></td>";
	col = row.insertCell(1);
	col.innerHTML = "<td><input name='unitcosts' type='text' size='8'/></td>";
	col = row.insertCell(2);
	col.innerHTML = "<td><input name='materialId' type='text' size='6'/></td>";
} 
*/

//分页导航javascript
function nextPage(action) {
	window.document.forms[0].action = window.document.forms[0].action + action;
	window.document.forms[0].submit();
}

//改变当前页面标题，在基础模块，新增修改为同一页面，当点击修改时，自动运行该函数，将新增改为修改
function getTitle(code, value) {
	str = document.getElementById(code);
	if (str.value != "") {
		var title = document.getElementById("info_top");
		title.innerHTML = value + "\u4fee\u6539";
	}
}
/*
	*复选框记录选取
	*选中所有的记录
	*/
var status = false;
function selectAll() {
	var a = document.getElementById("info_table").getElementsByTagName("input");
	if (status == false) {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = true;
			}
		}
		status = true;
	} else {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = false;
			}
		}
		status = false;
	}
}

//选中当前页面分为两部分的下一部分的复选框
function selectAllTwo() {
	var a = document.getElementById("info_table2").getElementsByTagName("input");
	if (status == false) {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = true;
			}
		}
		status = true;
	} else {
		for (var i = 0; i < a.length; i = i + 1) {
			if (a[i].type == "checkbox") {
				a[i].checked = false;
			}
		}
		status = false;
	}
}
/*
*
*顶部功能按钮区
*
*/

//新增按钮
function addAction(atn) {
	location.href = atn + ".action";
}


//修改按钮
function updateAction(action) {
	var checkboxNo = document.getElementsByName("rowlist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//formd的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num < 1) {
		alert("\u60a8\u8fd8\u6ca1\u6709\u8fdb\u884c\u9009\u62e9\uff01");
	} else {
		if (num > 1) {
			alert("\u6bcf\u6b21\u4fee\u6539\u53ea\u80fd\u9009\u62e9\u4e00\u6761\u8bb0\u5f55\uff01");
		} else {
			if (num == 1) {
				if (confirm("\u786e\u8ba4\u8981\u4fee\u6539\u8be5\u8bb0\u5f55\u5417\uff1f")) {
					delrow.action = action + ".action";
			//提交表单到action	
					delrow.submit();
				}
			}
		}
	}
}
//删除按钮
function deleteAction(action) {
	var checkboxNo = document.getElementsByName("rowlist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//formd的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num < 1) {
		alert("\u60a8\u8fd8\u6ca1\u6709\u8fdb\u884c\u9009\u62e9\uff01");
	} else {
		if (num > 0) {
			if (confirm("\u786e\u8ba4\u8981\u5220\u9664\u9009\u4e2d\u7684\u8bb0\u5f55\u5417\uff1f")) {
				delrow.action = action + ".action";
			//提交表单到action	
				delrow.submit();
			}
		}
	}
}



//审核功能js函数
//本函数只能进行单行审核
function AudingAction(action) {
	var checkboxNo = document.getElementsByName("rowlist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//form的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num < 1) {
		alert("\u60a8\u8fd8\u6ca1\u6709\u8fdb\u884c\u9009\u62e9\uff01");
	} else {
		if (num > 1) {
			alert("\u6bcf\u6b21\u53ea\u80fd\u5ba1\u6838\u4e00\u6761\u8bb0\u5f55\uff01");
		} else {
			if (num == 1) {
				if (confirm("\u786e\u8ba4\u8981\u5ba1\u6838\u8be5\u8bb0\u5f55\u5417\uff1f")) {
					delrow.action = action + ".action";
			//提交表单到action	
					delrow.submit();
				}
			}
		}
	}
}


//反审核功能js函数
//本函数只可以进行单行反审核
function unAudingAction(action) {
	var checkboxNo = document.getElementsByName("rowlist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//form的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num < 1) {
		alert("\u60a8\u8fd8\u6ca1\u6709\u8fdb\u884c\u9009\u62e9\uff01");
	} else {
		if (num > 1) {
			alert("\u6bcf\u6b21\u53ea\u80fd\u53cd\u5ba1\u6838\u4e00\u6761\u8bb0\u5f55\uff01");
		} else {
			if (num == 1) {
				if (confirm("\u786e\u8ba4\u8981\u53cd\u5ba1\u6838\u8be5\u8bb0\u5f55\u5417\uff1f")) {
					delrow.action = action + ".action";
			//提交表单到action	
					delrow.submit();
				}
			}
		}
	}
}

//采购价格资料限价
function priceControl(action) {
	var checkboxNo = document.getElementsByName("rowlist");//checkbox的名字
	//得到要提交的表单
	var delrow = document.getElementById("delrow");//formd的ID
	var num = 0;
	for (var i = checkboxNo.length - 1; i >= 0; i = i - 1) {
		if (checkboxNo[i].checked) {
			num = num + 1;
		}
	}
	if (num < 1) {
		alert("\u60a8\u8fd8\u6ca1\u6709\u8fdb\u884c\u9009\u62e9\uff01");
	} else {
		if (num > 1) {
			alert("\u6bcf\u6b21\u4fee\u6539\u53ea\u80fd\u9009\u62e9\u4e00\u6761\u8bb0\u5f55\uff01");
		} else {
			if (num == 1) {
				delrow.action = action + ".action";
			//提交表单到action	
				delrow.submit();
			}
		}
	}
}
//放大镜功能选择函数(子窗口操作父窗口，给父窗口传值)
//参数解释
//id:是你的放大镜页面中隐藏的id
//childId:选择页面上传过来的值
//name:是你的放大镜页面中文本框的name
//childName:选择页面上传过来的值
function childToParent(id, childId, name, childName) {
				//
	var parentId = window.opener.document.getElementById(id);
	var parentName = window.opener.document.getElementById(name);
	parentId.value = childId;
	parentName.value = childName;
	window.close();
}

function childToParentForInvoice(id, childId, name, childName,address,childAddress,openAccountBank,childOpenAccountBank
						,taxRegisterNo,childTaxRegisterNo) {
				//
	var parentId = window.opener.document.getElementById(id);
	var parentName = window.opener.document.getElementById(name);
	var parentAddress = window.opener.document.getElementById(address);
	var parentOpenAccountBank = window.opener.document.getElementById(openAccountBank);
	var parentTaxRegisterNo = window.opener.document.getElementById(taxRegisterNo);
	parentId.value = childId;
	parentName.value = childName;
	parentAddress.value = childAddress;
	parentOpenAccountBank.value = childOpenAccountBank;
	parentTaxRegisterNo.value = childTaxRegisterNo;
	window.close();
}

//放大镜选择功能函数--币别
function currencyChildToParent(id, childId, name, childName,rate,childRate) {
				//
	var parentId = window.opener.document.getElementById(id);
	var parentName = window.opener.document.getElementById(name);
	var parentRate = window.opener.document.getElementById(rate);
	parentId.value = childId;
	parentName.value = childName;
	parentRate.value = childRate ;
	window.close();
}
//放大镜功能选择函数(子窗口操作父窗口，给父窗口传值)
//参数解释
//id:是你的放大镜页面中隐藏的id
//childId:选择页面上传过来的值
//name:是你的放大镜页面中文本框的name
//childName:选择页面上传过来的值
function childToParentForMaterial(id, childId, name, childName, code, childCode, materialAttribute, childMaterialAttribute, spec, childSpec) {
				//
	var parentId = window.opener.document.getElementById(id);
	var parentName = window.opener.document.getElementById(name);
	var parentCode = window.opener.document.getElementById(code);
	var parentMaterialAttribute = window.opener.document.getElementById(materialAttribute);
	var parentSpec = window.opener.document.getElementById(spec);
	parentId.value = childId;
	parentName.value = childName;
	parentCode.value = childCode;
	parentMaterialAttribute.value = childMaterialAttribute;
	parentSpec.value = childSpec;
	window.close();
}
/*
 * 打开新窗口
 * link:链接地址
 * name:窗口的名称
 * width:窗口的宽度
 * height:窗口的高度
 * scroll:窗口是否有滚动条，1：有滚动条；0：没有滚动条
 */
function openWin(link, name, width, height, scroll) {
	var sb = scroll == "1" ? "1" : "0";
	var l = (screen.width - width) / 2;
	var t = (screen.height - height) / 2;
	var sFeatures = "left=" + l + ",top=" + t + ",height=" + height + ",width=" + width + ",center=1,scrollbars=" + sb + ",status=0,directories=0,channelmode=0";
	var openwin = window.open(link, name, sFeatures);
	if (!openwin.opener) {
		openwin.opener = self;
	}
	openwin.focus();
}
/*
*将要操作的会计科目文本框的id、name赋给隐藏在jsp中的accountbookId,accountbookName
*打开会计科目选择页面
*/
function multiSelect(hiddenName, hiddenId, link, name, width, height, scroll) {
   	//得到隐藏在jsp页面上的会计科目name
	var accountbookName = document.getElementById("accountbookName");
    
    //如果参数hiddenId的值不为''是（jsp面上需要id属性）
	if (hiddenId != "") {
		var accountbookId = document.getElementById("accountbookId");
		accountbookId.value = hiddenId;
		accountbookName.value = hiddenName;
	}
	else//jsp页面上不需要id属性
		accountbookName.value = hiddenName;
		
	//打开多选会计科目的select页面
	openWin(link, name, width, height, scroll);
}
//同一个页面多次调用员工选择页面
function multiSelect2(realName,realId,hiddenName, hiddenId, link, name, width, height, scroll) {
   	//得到隐藏在jsp页面上的会计科目name
	var accountbookName = document.getElementById(realName);
    
    //如果参数hiddenId的值不为''是（jsp面上需要id属性）
	if (hiddenId != "") {
		var accountbookId = document.getElementById(realId);
		accountbookId.value = hiddenId;
		accountbookName.value = hiddenName;
	}
	else//jsp页面上不需要id属性
		accountbookName.value = hiddenName;
		
	//打开多选会计科目的select页面
	openWin(link, name, width, height, scroll);
}

//同一个页面中多个放大镜的处理函数
function multiChildToParent(id, childId, name, childName) {
				//通过id和name参数值得到父页面中的隐藏元素
	var hiddenId = window.opener.document.getElementById(id);
	var hiddenName = window.opener.document.getElementById(name);
				//根据hiddenName隐藏元素的值来取得要操作的文本框（隐藏元素的值即为要操作文本框的id值）	
	var parentName = window.opener.document.getElementById(hiddenName.value);
				//页面上需要id和name
	if (hiddenId != null) {
		var parentId = window.opener.document.getElementById(hiddenId.value);
		parentId.value = childId;
	}
	parentName.value = childName;
	window.close();
}
function delrow() {
	
	var table = document.getElementById("info_table");
	var checkboxNo = document.getElementsByName("checkbox");
	var j = 0;
	var k = 0;
	
	for (var i = checkboxNo.length - 1; i > 0; i--) {
		if (checkboxNo[i].checked) {	
			k++;
			j = checkboxNo[i].parentElement.parentElement.rowIndex;
			table.deleteRow(j);
		}
	}
	if (k < 1) {
		alert("\u8bf7\u9009\u62e9\u4f60\u60f3\u8981\u5220\u9664\u7684\u8bb0\u5f55");
	}
}

//查看详情 action为你要请求显示明细的action， order为你要显示明细的单据名称
function showDetail(action, order) {
	
	var checkboxNo = document.getElementsByName("rowlist");
	//获得form表单
	var delrow = document.getElementById("delrow");
	var count = 0;
	for(var i = 0; i < checkboxNo.length; i ++) {
		if(checkboxNo[i].checked) {
			count ++;
		}
	}
	if (count < 1) {
		alert("请选择要查看的" + order + "！");
	} else if (count > 1) {
		alert("一次只能查看一个" + order + "！");
	} else {
		delrow.action = action + ".action";
		delrow.submit();
	}
	
}

